struct Node *connect(struct Node *x, struct Node *y, struct Node *z) {  
    struct Node *p = (struct Node *)malloc(sizeof(struct Node)), *head, *s;  
    head = p;  
    p->next = x;  
    x->next = NULL;  
    if (y->score > x->score) {  
        p->next = y;  
        y->next = x;  
    } else {  
        x->next = y;  
        y->next = NULL;  
    }  
    while (1) {  
        if (p->next == NULL || p->next->score < z->score) {  
            struct Node *temp = p->next;  
            p->next = z;  
            z->next = temp;  
            break;  
  
        }  
        p = p->next;  
    }  
    return head->next;  
}  